<template>
  <div class="fromPost">
    <el-form
      :model="numberValidateForm"
      ref="numberValidateForm"
      label-width="100px"
      class="demo-ruleForm"
      size="small"
      hide-required-asterisk
    >
      <div class="from-left">
        <el-form-item
          label="手机号码"
          prop="phone"
          :rules="[{ required: false }]"
        >
          <el-input
            type="phone"
            v-model.number="numberValidateForm.phone"
            autocomplete="off"
          ></el-input>
        </el-form-item>
        <el-form-item label="购次" prop="from" :rules="[{ required: false }]">
          <el-input
            type="from"
            v-model.number="numberValidateForm.from"
            autocomplete="off"
          ></el-input>
        </el-form-item>
        <el-form-item label="标签" prop="label" :rules="[{ required: false }]">
          <el-input
            type="label"
            v-model.number="numberValidateForm.label"
            autocomplete="off"
          ></el-input>
        </el-form-item>
      </div>
      <div class="from-right">
        <el-form-item
          label="客户身份"
          prop="card"
          :rules="[
            { required: false },
            { type: 'string', message: '请输入正确身份' },
          ]"
        >
          <el-input
            type="card"
            v-model.number="numberValidateForm.card"
            autocomplete="off"
          ></el-input>
        </el-form-item>
        <el-form-item label="会员卡" prop="vipCard">
          <el-input
            type="vipCard"
            v-model.number="numberValidateForm.vipCard"
            autocomplete="off"
            disabled
          ></el-input>
        </el-form-item>
        <el-form-item
          label="微信昵称"
          prop="wxName"
          :rules="[
            { required: false },
            { type: 'string', message: '请输入正确昵称' },
          ]"
        >
          <el-input
            type="wxName"
            v-model.number="numberValidateForm.wxName"
            autocomplete="off"
            disabled
          ></el-input>
        </el-form-item>
      </div>
      <el-form-item>
        <div class="from-mid">
          <span
            ><el-button type="primary" @click="submitForm(numberValidateForm)"
              >筛选</el-button
            ></span
          >
          <el-link type="primary" @click="resetForm('numberValidateForm')"
            >清空筛选条件</el-link
          >
        </div>
      </el-form-item>
    </el-form>
  </div>
</template>
<script>
import { regisUserApi } from "../http/httpUser";
import { regisSelectApi } from "../http/httpUser";
export default {
  name: "fromPost",
  data() {
    return {
      numberValidateForm: {
        phone: "",
        from: "",
        label: "",
        card: "",
        page: 1,
      },
    };
  },
  methods: {
    submitForm(numberValidateForm) {
      if (
        numberValidateForm.phone ||
        numberValidateForm.from ||
        numberValidateForm.label ||
        numberValidateForm.card
      ) {
        regisSelectApi(numberValidateForm)
          .then((res) => {
            if (res.data.code == 200) {
              console.log(res.data.data.resultUser);
              this.$store.commit("cusStore/creatcus", res.data.data.resultUser);
              this.$message.success("筛选成功");
            } else {
              this.$message.error("筛选失败");
            }
          })
          .catch();
      } else {
        this.$message.error("请填写信息");
      }

      // （筛选请求）
    },
    resetForm(formName) {
      this.$refs[formName].resetFields();
      regisUserApi(1)
        .then((res) => {
          if (res.data.code == 200) {
            this.$store.commit("cusStore/creatcus", res.data.data.userList);
          } else {
            console.log(res);
          }
        })
        .catch();
    },
  },
};
</script>
<style scoped lang='scss'>
@import "../assets/scss/baseColor";
.fromPost {
  background: $back-color;
  text-align: center;
  height: 250px;
  position: relative;
}

.from-left {
  width: 300px;
  position: absolute;
  left: 650px;
  top: 30px;
}
.from-right {
  width: 300px;
  position: absolute;
  left: 100px;
  top: 30px;
}
.from-mid {
  position: absolute;
  top: 180px;
  span {
    margin-right: 50px;
    margin-left: 30px;
  }
}
</style>